import net.minidev.json.JSONObject;

import java.util.Arrays;
import java.util.List;
import java.util.Set;

/**
 * @Author lzc
 * @Date 2022/4/17 11:53
 */
public class MapDemo {
    public static void main(String[] args) {
        JSONObject data = new JSONObject();
        data.put("a", "aa");
        data.put("c", "cc");
        data.put("b", "bb");
    
        List<String> sinkColumns = Arrays.asList("a,c".split(","));
    
        Set<String> keys = data.keySet();
    
       /* while (iterator.hasNext()) {
            String key = iterator.next();
            if (!sinkColumns.contains(key)) {
                iterator.remove();
            }
        }*/
    
        keys.removeIf(key -> !sinkColumns.contains(key));
    
        /*for (String key : keys) {
            if (!sinkColumns.contains(key)) {
                keys.remove(key);
            }
        }*/
        System.out.println(data);
    
    }
}
